{{ template "header"   . }}
{{ template "rankings" . }}

{{ $diamondDeltas := eq .Path "/rankings/misc/diamond-deltas" }}
{{ $mostTiedGolds := eq .Path "/rankings/misc/most-tied-golds" }}
{{ $oldestMedal   := hasPrefix .Path "/rankings/misc/oldest-" }}
{{ $solutions     := eq .Path "/rankings/misc/solutions" }}

{{ $hasGolfer := not $mostTiedGolds }}
{{ $hasHole   := or $diamondDeltas $mostTiedGolds $oldestMedal }}

<main id=two-pane>
    {{ template "nav" . }}

    <table class="nowrap-second{{ if $hasHole }}-third{{ end }} sticky">
        <thead>
            <tr>
                <th>#
            {{ if $hasGolfer }}
                <th>Golfer
            {{ end }}
            {{ if $hasHole }}
                <th>Hole
            {{ end }}
            {{ if $oldestMedal }}
                <th class=right>Submitted
            {{ else }}
                <th class=right>Total
            {{ end }}
            {{ if $solutions }}
                <th class=right>Bytes
                <th class=right>Chars
            {{ end }}
        <tbody>
        {{ $name := "" }}
        {{ with .Golfer }}{{ $name = .Name }}{{ end }}

        {{ range .Data.Rows }}
            <tr {{ if or .Me (and $hasGolfer (eq $name .Name)) }} class=me {{ end }}>
                <td>{{ comma .Rank }}<sup>{{ ord .Rank }}</sup>
            {{ if $hasGolfer }}
                <td>{{ template "golfer-link" . }}
            {{ end }}
            {{ if $hasHole }}
                <td>
                    <a href="/rankings/holes/{{ .Hole.ID }}/{{ .Lang.ID }}/{{ .Scoring }}">
                        {{ svg .Lang.ID }}
                        {{ svg .Scoring }}
                        <span>{{ .Hole.Name }}</span>
                    </a>
            {{ end }}
            {{ if $oldestMedal }}
                <td class=right>{{ time (.Submitted.In $.Location) }}
            {{ else }}
                <td class=right>{{ comma .Count }}
            {{ end }}
            {{ if $solutions }}
                <td class=right>{{ comma .Bytes }}
                <td class=right>{{ comma .Chars }}
            {{ end }}
        {{ end }}
    </table>

    {{ template "pagination" .Data.Pager }}
</main>

{{ template "footer" }}
